using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class SupportInfo
    {
		#region Local Variable
		public enum Field
		{
			ID,
			Nick,
			Email,
			Name,
			Position
		}
		private Int32 _ID;
		private String _Nick;
		private String _Email;
		private String _Name;
		private String _Position;
		
		public Int32 ID{	get{ return _ID;} set{_ID = value;} }
		public String Nick{	get{ return _Nick;} set{_Nick = value;} }
		public String Email{	get{ return _Email;} set{_Email = value;} }
		public String Name{	get{ return _Name;} set{_Name = value;} }
		public String Position{	get{ return _Position;} set{_Position = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public SupportInfo()
		{
			_ID = 0;
			_Nick = "";
			_Email = "";
			_Name = "";
			_Position = "";
		}
		public SupportInfo(
		Int32 ID,
		String Nick,
		String Email,
		String Name,
		String Position
		)
		{
			_ID = ID;
			_Nick = Nick;
			_Email = Email;
			_Name = Name;
			_Position = Position;
		}
		public SupportInfo(DataRow dr)
		{
			if (dr != null)
			{
				_ID = dr[Field.ID.ToString()] == DBNull.Value?0:Convert.ToInt32(dr[Field.ID.ToString()]);
				_Nick = dr[Field.Nick.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Nick.ToString()]);
				_Email = dr[Field.Email.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Email.ToString()]);
				_Name = dr[Field.Name.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Name.ToString()]);
				_Position = dr[Field.Position.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.Position.ToString()]);
			}
		}
		public SupportInfo(SupportInfo objEntr)
		{			
			_ID = objEntr.ID;			
			_Nick = objEntr.Nick;			
			_Email = objEntr.Email;			
			_Name = objEntr.Name;			
			_Position = objEntr.Position;			
		}
        #endregion Constructor
        
        #region InitTable
		public DataTable ToDataTable()
		{
			DataTable dt = new DataTable("Support");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.ID.ToString(), typeof(Int32)),
				new DataColumn(Field.Nick.ToString(), typeof(String)),
				new DataColumn(Field.Email.ToString(), typeof(String)),
				new DataColumn(Field.Name.ToString(), typeof(String)),
				new DataColumn(Field.Position.ToString(), typeof(String))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.ID.ToString()] = _ID;
			row[Field.Nick.ToString()] = _Nick;
			row[Field.Email.ToString()] = _Email;
			row[Field.Name.ToString()] = _Name;
			row[Field.Position.ToString()] = _Position;
			return row;
		}
        #endregion InitTable
    }
}
